home *** CD-ROM | disk | FTP | other *** search
- {******************************************************************}
- { }
- { Mancala }
- { Turbo Pascal for Windows }
- { Copyright (c) 1991 by Swan Software. All rights reserved. }
- { }
- {******************************************************************}
-
- { uoptions.pas -- Options dialog for Mancala }
-
- unit UOptions;
-
- interface
-
- uses WinTypes, WinProcs, WObjects, UGlobals, Idents;
-
- const
-
- ppcLen = 2; { Length of Pepples per cup input field }
-
- type
-
- POptionsRec = ^OptionsRec; { Pointer to OptionsRec record }
- OptionsRec = record
- PPCLine: array[0 .. ppcLen] of Char;
- end;
-
- POptDialog = ^OptDialog;
- OptDialog = object(TDialog)
- DataPointer: POptionsRec;
- constructor Init(AParent: PWindowsObject; AName: PChar;
- P: POptionsRec);
- procedure SetupWindow; virtual;
- procedure Ok(var Msg: TMessage);
- virtual id_First + id_Ok;
- end;
-
-
- implementation
-
-
- {- Initialize edit control identified by CtrlID with text in Buffer.
- HDlg is the dialog window handle; MaxLen is the maximum number of
- characters that can be entered into the control.}
-
- procedure SetText(HDlg: HWnd; CtrlID: Word; Buffer: PChar; MaxLen: Word);
- begin
- SendDlgItemMessage(HDlg, CtrlID, wm_SetText, 0, LongInt(Buffer));
- SendDlgItemMessage(HDlg, CtrlID, em_LimitText, MaxLen, 0);
- end;
-
-
- {- Retrieve text from edit control identified by CtrlID. Text is
- copied to the array addressed by Buffer. MaxLen equals the maximum
- number of bytes to copy, including the null terminator.}
-
- procedure GetText(HDlg: HWnd; CtrlID: Word; Buffer: PChar; MaxLen: Word);
- begin
- SendDlgItemMessage(HDlg, CtrlID, wm_GetText, MaxLen, LongInt(Buffer));
- end;
-
-
- {- Construct OptDialog instance. P addresses dialog data record. }
-
- constructor OptDialog.Init(AParent: PWindowsObject; AName: PChar;
- P: POptionsRec);
- begin
- TDialog.Init(AParent, AName);
- DataPointer := P; { Save pointer to caller's dialog record }
- end;
-
-
- {- Prepare initial control values }
-
- procedure OptDialog.SetupWindow;
- begin
- TDialog.SetupWindow;
- SetText(HWindow, op_PebblesPerCup, DataPointer^.PPCLine, ppcLen);
- end;
-
-
- {- Respond to Ok button }
-
- procedure OptDialog.Ok(var Msg: TMessage);
- begin
- GetText(HWindow, op_PebblesPerCup, DataPointer^.PPCLine, ppcLen + 1);
- TDialog.Ok(Msg);
- end;
-
-
- end.
-
-
- { ----------------------------------------------------------------
- Copyright (c) 1991 by Swan Software. All rights reserved.
- Revision 1.00 Date: 8/21/1991
- ---------------------------------------------------------------- }
-